package com.yanqu.road.server.cmd.banquet;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.banquet.BanquetProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.banquet.BanquetRelationshipMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

import java.util.List;

@Cmd(code = GameProtocol.S_CROSS_RELATIONSHIP_INIT_SYNC, desc = "")
public class BanquetRelationshipInitCmd implements Command {
    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        BanquetProto.CrossBanquetRelationshipRespMsg respMsg = BanquetProto.CrossBanquetRelationshipRespMsg.parseFrom(packet.getBytes());
        List<BanquetProto.BanquetRelationshipDataMsg> dataList = respMsg.getDataList();
        BanquetRelationshipMgr.initUserBanquetRelationShip( dataList);

        BanquetProto.CrossBanquetRelationshipAckMsg.Builder ackMsg = BanquetProto.CrossBanquetRelationshipAckMsg.newBuilder();
        YanQuMessage message = YanQuMessageUtils.buildMessage(CrossProtocol.C_CROSS_BANQUET_RELATIONSHIP_SYNC, ackMsg);
        GamePlayerMgr.sendPacket(0,message);

    }
}
